package com.fourforfo.common.to.es;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * PUT product
 * {
 *   "mappings": {
 *     "properties": {
 *       "skuId": {
 *         "type": "long"
 *       },
 *       "spuId": {
 *         "type": "keyword"
 *       },
 *       "skuTitle": {
 *         "type": "text",
 *         "analyzer": "ik_smart"
 *       },
 *       "skuPrice": {
 *         "type": "keyword"
 *       },
 *       "skuImg": {
 *         "type": "keyword",
 *         "index": false,
 *         "doc_values": false
 *       },
 *       "saleCount": {
 *         "type": "long"
 *       },
 *       "hasStock": {
 *         "type": "boolean"
 *       },
 *       "hotScore": {
 *         "type": "long"
 *       },
 *       "brandId": {
 *         "type": "long"
 *       },
 *       "catalogId": {
 *         "type": "long"
 *       },
 *       "brandName": {
 *         "type": "keyword",
 *         "index": false,
 *         "doc_values": false
 *       },
 *       "brandImg": {
 *         "type": "keyword",
 *         "index": false,
 *         "doc_values": false
 *       },
 *       "catalogName": {
 *         "type": "keyword",
 *         "index": false,
 *         "doc_values": false
 *       },
 *       "attrs": {
 *         "type": "nested",
 *         "properties": {
 *           "attrId": {
 *             "type": "long"
 *           },
 *           "attrName": {
 *             "type": "keyword",
 *             "index": false,
 *             "doc_values": false
 *           },
 *           "attrValue": {
 *             "type": "keyword"
 *           }
 *         }
 *       }
 *     }
 *   }
 * }
 */
//商品检索服务保存在ElasticSearch中的数据模型
@Data
public class SkuEsModel {

    private Long skuId;

    private Long spuId;

    private String skuTitle;//sku标题，用作全文检索

    private BigDecimal skuPrice;//sku价格

    private String skuImg;//sku图片链接，冗余字段

    private Long saleCount;//销量

    private Boolean hasStock;//是否有库存，当库存从无到有或者从有到无时才更新，减少ElasticSearch压力，库存为0时不被搜索到

    private Long hostScore;//热度值，按点击量来计算

    private Long brandId;//品牌id

    private Long catalogId;//商品分类id

    private String brandName;//品牌名，冗余字段

    private String brandImg;//品牌图片链接，冗余字段

    private String catalogName;//分类名，冗余字段

    private List<Attr> attrs;//属性集合

    @Data
    public static class Attr{
        private Long attrId;

        private String attrName;//属性名

        private String attrValue;//属性值
    }

}
